home *** CD-ROM | disk | FTP | other *** search
- ifdef DOCUMENTATION
- ; ****************************** DOCZ Header *********************************
- .MODULE delstr
- .LIBRARY csub
- .TYPE function
- .APPLICATION string
- .SYSTEM msdos-s
- .SYSTEM msdos-l
- .SYSTEM vms
- .SYSTEM unix
- .AUTHOR Software Toolz
- .DESCRIPTION
- Deletetion of characters within a string
- .ARGUMENTS
- char *delstr(str,pos,len)
- char *str; /* (r/w) input/output string */
- int pos, /* (r) index to start deletion */
- len; /* (r) no. of characters to delete */
- .NARRATIVE
- Delete "len" characters from "str", starting at "pos". Deletion is
- done in place (no buffer req'd).
- .LANGUAGE
- MSDOS small model & VMS, Assembly; all others, C
- .RETURNS
- A pointer to your string.
- .EXAMPLE
- char buff[128];
- strcpy(buff,"this is a poor test");
- delstr(buff,10,5);
- .REVISIONS 1/28/87
- Add return pointer to string instead of "void" (and rewrite in Assembly).
- .NOTICE
- Copyright 1989 Software Toolz, Inc. - Atlanta, Georgia
-
- All rights reserved worldwide. This program may not be reproduced,
- transmitted, transcribed, stored in a retrieval system or translated in
- any human or computer language, in any form without the express written
- permission of Software Toolz, Inc.
- .ENDOC END DOCUMENTATION
- ; ***************************************************************************
- endif
-
- INCLUDE C.MAC ; symbols and macros for Microsoft
-
- SFRAME STRUC
- SAV_SI DW ?
- SAV_DI DW ?
- SAV_ES DW ?
- REG_BP DW ? ; base pointer to be pushed
- RTN_ADD DW ? ; offset of return address
- STR DW ?
- POS DW ?
- LEN DW ?
- SFRAME ENDS
-
- ; ***************************************************************************
- ; code
- ; ***************************************************************************
- PSEG ; begin program section
-
- CFEXT strlen
- CFUN delstr
-
- PUSH BP
- PUSH ES
- PUSH DI
- PUSH SI
- MOV BP,SP
- MOV AX,DS
- MOV ES,AX
-
- MOV AX,[BP].STR ; calculate address of last string
- ADD AX,[BP].POS
- ADD AX,[BP].LEN
- PUSH AX
- CCALL strlen ; find length of last string
- MOV SP,BP
- MOV CX,AX
- INC CX ; include NULL
-
- CLD
- MOV SI,[BP].STR ; get string address
- ADD SI,[BP].POS ; calculate destination address
- MOV DI,SI
- ADD SI,[BP].LEN ; calculate source address
- REP MOVSB ; do the copy
-
- MOV AX,[BP].STR ; copy string address for return
-
- POP SI
- POP DI
- POP ES
- POP BP
- RET
-
- CFEND delstr
- ENDPS ; end program section
- END
-